<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/5/24
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>头部页面</title>
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
  <img src="${pageContext.request.contextPath}/img/logo.png" />
  <c:if test="${empty admin}">
      请<a href="javascript:void(0)" onclick="btnLogin()" class="btn btn-primary">登录</a>
  </c:if>
  <c:if test="${not empty admin}">
      <div style="float: right;">
                                                <%--avascript:void(0)超链接失效--%>
          欢迎<strong>${admin.username}</strong> <a href="javascript:void(0)" class="btn btn-warning" onclick="logOut()" >[退出]</a>
      </div>

  </c:if>
</body>
<script>

        //打开登录页面
        function  btnLogin(){
            top.location.href="${pageContext.request.contextPath}/admin/admin_login.jsp";

        }
        function  logOut(){
                //alert("点击事件触发") ;
            //跳转到后端地址完成退出
            //window.location.href="${pageContext.request.contextPath}/logOut"
            //window:窗口对象,直接当前指定的frame框架中打开页面
            //top:属于window里面:从顶部直接打开页面
            top.location.href="${pageContext.request.contextPath}/admin?methodName=logOut"
        }
</script>
</html>
